package com.xiaoshuidi.cloud.module.report.dal.mapper;

import com.baomidou.mybatisplus.annotation.InterceptorIgnore;
import com.xiaoshuidi.cloud.framework.mybatis.core.mapper.BaseMapperX;
import com.xiaoshuidi.cloud.module.report.dal.DO.FinanceMoneyFlowDO;
import com.xiaoshuidi.cloud.module.report.dal.dto.FinanceMoneyFlowDTO;
import com.xiaoshuidi.cloud.module.report.xxljob.PO.CollectionHandlePO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.List;

/**
 * 支付
 *
 * @author
 */
@Mapper
@InterceptorIgnore(tenantLine = "true")
public interface FinanceMoneyFlowMapper extends BaseMapperX<FinanceMoneyFlowDO> {

    BigDecimal selectPreRechargeInOrder(@Param("contractNo")String contractNo,@Param("startTime")LocalDateTime startTime,@Param("endTime")LocalDateTime endTime);

    @Select("select * from finance_money_flow where flow_no =#{flowNo} and deleted=0 limit 1")
    FinanceMoneyFlowDO selectByFlowNo(@Param("flowNo")String flowNo);

    BigDecimal sumTodayCashIncome(@Param("tenantId")Long tenantId,@Param("apartmentId")Long apartmentId);

    BigDecimal sumTodayIncome(@Param("tenantId")Long tenantId,@Param("apartmentId")Long apartmentId);

    BigDecimal sumTotalInCurrentMonth(@Param("tenantId")Long tenantId,@Param("apartmentId")Long apartmentId);

    BigDecimal sumTotalInCurrentYear(@Param("tenantId")Long tenantId,@Param("apartmentId")Long apartmentId);

    Long countSummaryByParam(CollectionHandlePO collectionHandlePO);
    List<FinanceMoneyFlowDTO> selectSummaryByParam(CollectionHandlePO collectionHandlePO);

}
